<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.*,
						com.ophelisis.common.util.*,
						com.ophelisis.common.consts.*"%>
						
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=ConstPath.siteTitle%></title>
<link href="css/common.css" rel="stylesheet" />
<link href="css/calendar/ui.all.css" rel="stylesheet" />
<script src="js/jquery-1.7.2.js"></script>
<script src="js/common.js"></script>
<script src="js/calendar/ui.datepicker.js"></script>
<script src="js/calendar/jquery.ui.datepicker-ko.js"></script>
<script>
var url = "boardCalendarMgmt.action";
var targetElement = "ajaxDivList";

var d = new Date();
var year = d.getFullYear();

$.datepicker.setDefaults({
	dateFormat: 'yy-mm-dd',
	buttonImageOnly: true,
	buttonText: "달력",
    changeYear: true, 
    yearRange: (year - 100) + ":" + (year + 10),
	buttonImage: "css/calendar/images/calendar.gif" 
});

var popupModule = {
		reset: function() {
			$("#popupForm").each(function(){
				this.reset();
			});
			
			parent.NcloseLayer();
		},
		
		save: function() {
			var calendarNm = $("#calendarNm");
			if (calendarNm.val() == "") {
				alert("제목을 입력하여 주십시오.");
				calendarNm.focus();
				return;
			}

			var calendarDesc = $("#calendarDesc");
			if (calendarDesc.val() == "") {
				alert("내용을 입력하여 주십시오.");
				calendarDesc.focus();
				return;
			}
			
			if (!confirm("해당 항목을 저장합니다. 계속 하시겠습니까?")) {
				return;
			}

			var rParams = "target=bmSave&" + parent.$("#commonForm").serialize() + "&" + $("#popupForm").serialize();

			this.makeList(url, rParams);
		},
		
		makeList: function(sUrl, sParams) {
			$.ajax({
				url : sUrl,
				type : "POST",
				data : sParams,
				dataType : "html",
				success : function(data){
					parent.$("#" + targetElement).html(data);

					parent.pmModule.setUnbinding();
					parent.pmModule.setBinding();
					parent.pmModule.initPage();
					parent.NcloseLayer();
				}
			});
		}
};

$(document).ready(function() {
	$("#startDate, #endDate").datepicker({
        showOn: "both", // focus, button, both
        showAnim: "fadeIn", // show, fadeIn, slideDow
        onSelect : function(dateText, inst) {
        }
	});
});
</script>
</head>
<body>
<div id="formlist1" class="noborder">
	<input type="hidden" id="loadCheck" name="loadCheck" value="OK" />
	<form id="popupForm" name="popupForm" method="post">
		<input type="hidden" id="isNew" name="isNew" value="Y" />
		<table class="viewstyle1">
			<colgroup>
				<col width="120" />
				<col width="200" />
				<col width="120" />
				<col width="" />
			</colgroup>
			<tr>
				<td colspan="4" class="titleColumn">기본 정보</td>
			</tr>
			<tr>
				<th>제목</th>
				<td colspan="3"><input type="text" id="calendarNm" name="calendarNm" class="in3 intex_l width_400p" value="" /></td>
			</tr>
			<tr>
				<th>내용</th>
	            <td colspan="3"><textarea id="calendarDesc" name="calendarDesc" class="width_400p height_100p"></textarea></td>
			</tr>
			<tr>
				<td colspan="4" class="titleColumn">기간 정보</td>
			</tr>
			<tr>
				<th>시작</th>
				<td><input type="text" id="startDate" name="startDate" class="in3 intex_l width_80p" value="${_startDay}" readonly="readonly" /></td>
				<th>종료</th>
				<td><input type="text" id="endDate" name="endDate" class="in3 intex_l width_80p" value="${_endDay}" readonly="readonly" /></td>
			</tr>
		</table>
	</form>
	<div id="lowbtn">
		<a href="javascript:popupModule.reset();"><img src="images/btn/btn_cancel01.gif" /></a>
		<a href="javascript:popupModule.save();"><img src="images/btn/btn_save01.gif" /></a>  
	</div>
</div>
</body>
</html>
